<%@ page import="njust.user.Login" %>
<%@ page import="njust.user.UserDAO" %>
<%@ page import="njust.utils.DBUtil" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page import="njust.hitcourse.HitCourseDAO" %>
<%@ page import="njust.course.CourseDAO" %><%--
  Created by IntelliJ IDEA.
  User: 25174
  Date: 2022/4/24
  Time: 16:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<script>

</script>
<%
    //login即为当前登录者的相关信息
    Login login= (Login) session.getAttribute("userinfo");
    UserDAO userDAO=new UserDAO();
    CourseDAO courseDAO=new CourseDAO();
    HitCourseDAO hitCourseDAO=new HitCourseDAO();
    int count=0;//充当计数工具
    List<Map<String, Object>> listCourseByUserIds = hitCourseDAO.getListCourseByUserId(userDAO.getUserId(login));
%>
学号：<%=userDAO.getUserId(login)%>  姓名：<%=login.getName()%>
<form action="CourseController">
<%--   ------------------------------------------------------------------------------ --%>
    <table border="1" width="600" id = "courseT">
        <tr>
            <td align = "center"></td>
            <td align = "center">序号</td>
            <td align = "center">课程名称</td>
            <td align = "center">分数</td>
        </tr>
        <%
            for(Map<String, Object> map:listCourseByUserIds){
        %>
        <tr>
            <%--     记录的是当前登陆者所选课程的cId     --%>
            <td align = "center"><input name="hitCourseId" type="checkbox" value=<%=map.get("cId") +""%> ></td>

            <td align = "center"><%=++count %></td>
            <td align = "center"><%=courseDAO.findCourseById((Integer) map.get("cId")).getCourseName() %></td>
            <td align = "center"><%=map.get("score") %></td>

        </tr>
        <%
            }
        %>
        <input type="hidden" name="courseFormCheck" value="withDrawCourse">
    </table>
    <%--   ------------------------------------------------------------------------------ --%>
    <br>
    <%--退选按钮--%>
    <input type="submit" name="withdrawalButton" value="退课">
    <input type="button" name="allCourseButton" value="课程管理" onclick="window.location.href='allCourse.jsp';">
</form>

</body>
</html>
